<template>
  <div class="user-info">
    <div class="avatar no-drag">
      <img v-if="user.avatar != undefined && user.avatar != ''" :src="user.avatar">
      <img v-else src="../../assets/images/max.png"/>
    </div>
    <div class="mt-5">
      {{ user.realName }}
      <el-button style="color: #555;" type="text" class="no-drag" size="mini" @click="logout">
        注销
      </el-button>
    </div>
<!--    <div class="font-assist  type-icons">-->
<!--      <i class="iconfont icon-LV5"></i>-->
<!--      <i class="iconfont icon-vip"></i>-->
<!--    </div>-->
  </div>
</template>
<script>
import {mapState} from 'vuex'

export default {
  methods: {
    logout() {
      this.$confirm('此操作将退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http.post('/api/logout')
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消登出'
        });
      });
    }
  },
  computed: {
    ...mapState(['user'])
  }
}
</script>
<style lang="scss" scoped>
.user-info {
  -webkit-app-region: drag;
  height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .avatar {
    width: 50px;
    height: 50px;
    img {
      width: 100%;
      height: 100%;
      border-radius: 50%;
      cursor: pointer;
    }
  }
  .type-icons {
    display: flex;
    justify-content: center;
    i {
      font-size: 22px;
      color: #999;
      margin-left: 8px;
    }
    i:first-child{
      margin-left: 0;
    }
  }
}
</style>
